package com.demo.controller;

import com.demo.core.constants.HttpStatus;
import com.demo.core.domain.Result;
import com.demo.domain.TournamentArrangement;
import com.demo.service.TournamentArrangementService;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
public class TournamentArrangementController {
    @Autowired
    public TournamentArrangementService tournamentArrangementService;

    /**
     * 得到所有赛程安排
     *
     * @return
     */
    @Operation(summary = "得到所有赛程安排")
    @PostMapping("/getAllArrangements")
    public Result getAllArrangements() throws Exception {
//            得到所有记录
        List<TournamentArrangement> list = tournamentArrangementService.getAllArrangements();
        return list != null && list.size() > 0 ?
                Result.success(HttpStatus.SUCCESS, "查找成功", list) :
                Result.success(HttpStatus.SUCCESS, "无赛程信息", new ArrayList<>());
    }
}
